﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Common.Infrastructure
{
    /// <summary>
    /// 字段索引属性
    /// </summary>
    [AttributeUsage(AttributeTargets.Property, Inherited = true)]
    public class EntityFieldIndexAttribute : Attribute
    {
        private bool isUnique = false;
        private bool isUniqueByOrg = false;

        /// <summary>
        /// 
        /// </summary>
        /// <param name="isUnique">是否唯一索引</param>
        /// <param name="isUniqueByOrg">同组织唯一</param>
        public EntityFieldIndexAttribute(bool isUnique, bool isUniqueByOrg)
            : base()
        {
            this.isUnique = isUnique;
            this.isUniqueByOrg = isUniqueByOrg;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="isUnique">是否唯一索引</param>
        public EntityFieldIndexAttribute(bool isUnique)
            : base()
        {
            this.isUnique = isUnique;
        }

        public EntityFieldIndexAttribute()
            : this(false)
        {
        }

        /// <summary>
        /// 是否唯一索引
        /// </summary> 
        public bool IsUnique
        {
            get { return isUnique; }
        }

        /// <summary>
        /// 是否唯一索引
        /// </summary> 
        public bool IsUniqueByOrg
        {
            get { return isUniqueByOrg; }
        }
    }
}
